const board = {
  boardE: document.getElementById('scoreboard'),
  objs: {},
  addObjective(name, display) {
    if (board.objs[name]) {
      return
    }
    board.objs[name] = {}
    if (display) {
      board.showObjective(name)
    }
  },
  removeObjective(name) {
    board.hideObjective(name)
    delete board.objs[name]
  },
  showObjective(name) {
    if (!board.objs[name] || board.objs[name].element) {
      return
    }
    const e = document.createElement('div')
    e.className = 'scoreboard-obj'
    e.innerHTML = '<div class="scoreboard-title"></div><div></div>'
    e.children[0].innerText = name
    board.objs[name].element = e
    board.boardE.appendChild(e)
  },
  hideObjective(name) {
    if (!board.objs[name] || !board.objs[name].element) {
      return
    }
    board.boardE.removeChild(board.objs[name].element)
    board.objs[name].element = null
  }
}
